import { request } from "@/utils/service"
import type * as Dy from "./types/dy"
import { getToken } from "@/utils/cache/cookies"
import axios from "axios"
const baseURL = import.meta.env.VITE_BASE_API
/** -----------------店铺相关接口 ---------------------------------*/
/** 增 */
export function createDyDataApi(data: Dy.ICreateDyRequestData) {
  return request({
    url: "order/dyShop/add",
    method: "post",
    data
  })
}

/** 删 */
export function deleteDyDataApi(id: string) {
  return request({
    url: "order/dyShop/del",
    method: "delete",
    params: {
      id
    }
  })
}

/** 改 */
export function updateDyDataApi(data: Dy.ICreateDyRequestData) {
  return request({
    url: "order/dyShop/update",
    method: "put",
    data
  })
}

/** 查 */
export function getDyDataApi(params: Dy.IGetDyRequestData) {
  return request<any>({
    url: "order/dyShop/query",
    method: "get",
    params
  })
}
/** -----------------------------E N D------------------------------------ */
/**订单相关接口 */

export function getDyListDataApi(params: Dy.IGetDyRequestData) {
  return request<any>({
    url: "capture/dy/getOrderList",
    method: "get",
    params
  })
}

//订单提交
export function pushDyOrder(data: any, userId: any) {
  return request<any>({
    url: `capture/dy/submit?userId=${userId}`,
    method: "post",
    data
  })
}

// //订单自动提交开关
export function Autopush(data: any) {
  return axios({
    url: `${baseURL}/timingTask/open`,
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data",
      token: getToken()
    },
    data
  })
}
// 订单是否留存
export function offspush(data: any) {
  return request<any>({
    url: "/order/dyShop/updateOffs",
    method: "post",
    data
  })
}
// 人工退款
export function ReturnPrice(data: any) {
  return request({
    url: "/capture/dy/refundOrder",
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data",
      token: getToken()
    },
    data
  })
}
// 审核通过
export function ReturnPriceOK(data: any) {
  return request({
    url: "/capture/dy/okOrder",
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data",
      token: getToken()
    },
    data
  })
}

/** 留存查 */
export function getDyqueryPageApi(params: any) {
  return request<any>({
    url: "/order/dy/queryPage",
    method: "get",
    params
  })
}
// 提交
export function dyShopupda(data: any) {
  return request<any>({
    url: "/order/dy/submit",
    method: "post",
    data
  })
}
// 修改订单类型
export function dyupdateType(data: any) {
  return request<any>({
    url: "/order/dy/updateType",
    method: "post",
    data
  })
}
